export function innerAppColumns() {
  return [
    {
      title: this.$t("module.appManage.appCode"),
      key: "applicationCode",
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.applicationCode
            }
          },
          params.row.applicationCode
        );
      }
    },
    {
      title: this.$t("module.appManage.appName"),
      key: "applicationName",
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.applicationName
            }
          },
          params.row.applicationName
        );
      }
    }
  ];
}

export function outerAppColumns() {
  return [
    {
      title: this.$t("module.appManage.appCode"),
      key: "vsiKey",
      width: 150,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.vsiKey
            }
          },
          params.row.vsiKey
        );
      }
    },
    {
      title: this.$t("module.appManage.appName"),
      key: "vsiValue",
      width: 150,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.vsiValue
            }
          },
          params.row.vsiValue
        );
      }
    },
    {
      title: this.$t("module.appManage.messageSubject"),
      key: "remark",
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.vsiDescription
            }
          },
          params.row.vsiDescription
        );
      }
    }
  ];
}

export function appAssignUserColumns() {
  const COLUMN_WIDTH = window.RPConfig.COLUMN_WIDTH
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "userId",
      minWidth: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userId
            }
          },
          params.row.userId
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "userName",
      minWidth: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userName
            }
          },
          params.row.userName
        );
      }
    },
    {
      title: this.$t("module.userManage.cellPhoneNumber"),
      key: "mobile",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_MOBILE,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_MOBILE + COLUMN_WIDTH.MAX_WIDTH_MORE,

    },
    {
      title: this.$t("module.userManage.email"),
      key: "email",
      align: "center",
      minWidth: COLUMN_WIDTH.COLUMN_WIDTH_EMAIL,
      maxWidth: COLUMN_WIDTH.COLUMN_WIDTH_EMAIL + COLUMN_WIDTH.MAX_WIDTH_MORE,
    },
    {
      title: this.$t("module.userManage.organization"),
      key: "orgName",
      minWidth: 160,
      render: (h, params) => {
        if (params.row._hasOrgInfo) {
          return h(
            "div",
            {
              attrs: {
                class: "ivu-table-cell ivu-table-cell-ellipsis",
                title: params.row.orgNameFullPath
              }
            },
            params.row.orgName
          );
        } else {
          return h("Spin", [
            h("Icon", {
              props: {
                type: "ios-loading",
                size: 18
              },
              class: "spin-icon-load"
            })
          ]);
        }
      }
    },
    {
      title: this.$t("common.operating"),
      align: "center",
      fixed: "right",
      width: 55,
      render: (h, params) => {
        let operations = [];
        if ("RIPPLES.crc" != this.appCode || (params.row.category != 1 && params.row.category != 2)) {
          operations = [
            {
              type: "icon",
              icon: "ios-trash",
              text: this.$t("common.delete"),
              handle: () => {
                this.deleted(params.row.id);
              }
            }
          ];
        }
        return h("RowTools", {
          props: {
            data: operations
          }
        });
      }
    }
  ];
}

export function appSelectUserColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "userId",
      width: 180,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userId
            }
          },
          params.row.userId
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "userName",
      width: 180,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userName
            }
          },
          params.row.userName
        );
      }
    },
    {
      title: this.$t("module.userManage.cellPhoneNumber"),
      key: "mobile",
      width: 100
    },
    {
      title: this.$t("module.userManage.email"),
      key: "email",
      minWidth: 160
    },
    {
      title: this.$t("module.userManage.organization"),
      key: "orgName",
      minWidth: 160,
      render: (h, params) => {
        if (params.row._hasOrgInfo) {
          return h(
            "div",
            {
              attrs: {
                class: "ivu-table-cell ivu-table-cell-ellipsis",
                title: params.row.orgNameFullPath
              }
            },
            params.row.orgName
          );
        } else {
          return h("Spin", [
            h("Icon", {
              props: {
                type: "ios-loading",
                size: 18
              },
              class: "spin-icon-load"
            })
          ]);
        }
      }
    }
  ];
}
